| Conditions | 12 |
| Total Lines | 74 |
| Code Lines | 49 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
Complex classes like 17.bundle.bc95065f8ba2bf43a86c.js ➔ installOpenLayersRenderer often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | (window["webpackJsonp"] = window["webpackJsonp"] || []).push([[17],{ |
||
| 74 | value: function installOpenLayersRenderer(container, displaySet) { |
||
| 75 | var _this2 = this; |
||
| 76 | |||
| 77 | var dicomWebClient = displaySet.dicomWebClient; |
||
| 78 | var searchInstanceOptions = { |
||
| 79 | studyInstanceUID: displaySet.StudyInstanceUID, |
||
| 80 | seriesInstanceUID: displaySet.SeriesInstanceUID |
||
| 81 | }; |
||
| 82 | dicomWebClient.searchForInstances(searchInstanceOptions).then(function (instances) { |
||
| 83 | var promises = []; |
||
| 84 | |||
| 85 | for (var i = 0; i < instances.length; i++) { |
||
| 86 | var sopInstanceUID = instances[i]['00080018']['Value'][0]; |
||
| 87 | var retrieveInstanceOptions = { |
||
| 88 | studyInstanceUID: displaySet.StudyInstanceUID, |
||
| 89 | seriesInstanceUID: displaySet.SeriesInstanceUID, |
||
| 90 | sopInstanceUID: sopInstanceUID |
||
| 91 | }; |
||
| 92 | var promise = dicomWebClient.retrieveInstanceMetadata(retrieveInstanceOptions).then(function (metadata) { |
||
| 93 | var ImageType = metadata[0]['00080008']['Value']; |
||
| 94 | |||
| 95 | if (ImageType[2] === 'VOLUME') { |
||
| 96 | return metadata[0]; |
||
| 97 | } |
||
| 98 | }); |
||
| 99 | promises.push(promise); |
||
| 100 | } |
||
| 101 | |||
| 102 | return Promise.all(promises); |
||
| 103 | }).then( |
||
| 104 | /*#__PURE__*/ |
||
| 105 | function () { |
||
| 106 | var _ref = _asyncToGenerator( |
||
| 107 | /*#__PURE__*/ |
||
| 108 | regeneratorRuntime.mark(function _callee(metadata) { |
||
| 109 | var _ref2, api, microscopyViewer; |
||
| 110 | |||
| 111 | return regeneratorRuntime.wrap(function _callee$(_context) { |
||
| 112 | while (1) { |
||
| 113 | switch (_context.prev = _context.next) { |
||
| 114 | case 0: |
||
| 115 | metadata = metadata.filter(function (m) { |
||
| 116 | return m; |
||
| 117 | }); |
||
| 118 | _context.next = 3; |
||
| 119 | return __webpack_require__.e(/* import() | dicom-microscopy-viewer */ 10).then(__webpack_require__.t.bind(null, 1003, 7)); |
||
| 120 | |||
| 121 | case 3: |
||
| 122 | _ref2 = _context.sent; |
||
| 123 | api = _ref2.api; |
||
| 124 | microscopyViewer = api.VLWholeSlideMicroscopyImageViewer; |
||
| 125 | _this2.viewer = new microscopyViewer({ |
||
| 126 | client: dicomWebClient, |
||
| 127 | metadata: metadata, |
||
| 128 | retrieveRendered: false |
||
| 129 | }); |
||
| 130 | |||
| 131 | _this2.viewer.render({ |
||
| 132 | container: container |
||
| 133 | }); |
||
| 134 | |||
| 135 | case 8: |
||
| 136 | case "end": |
||
| 137 | return _context.stop(); |
||
| 138 | } |
||
| 139 | } |
||
| 140 | }, _callee); |
||
| 141 | })); |
||
| 142 | |||
| 143 | return function (_x) { |
||
| 144 | return _ref.apply(this, arguments); |
||
| 145 | }; |
||
| 146 | }()); |
||
| 147 | } |
||
| 148 | }, { |
||
| 182 | }]); |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.